package com.lesama.producer_consumer;

public class Consumer implements Runnable {

    @Override
    public void run() {
        while (true) {
            WorkHouse.lock.lock();
            if(WorkHouse.mark) {
                System.out.println("消费者消费了西瓜冰棒");
                WorkHouse.mark = false;
                WorkHouse.producer.signal();
            } else {
                try {
                    WorkHouse.consumer.await();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            WorkHouse.lock.unlock();
        }
    }
}
